package com.liu.thredState_study;

public class Text {
    public static void main(String[] args) throws InterruptedException {
        /**
         * 创建线程
         */
        MyThread myThread = new MyThread();

        System.out.println("状态新建========="+myThread.isAlive());
        /**
         * 线程启动
         */
        myThread.start();
        System.out.println("状态启动========="+myThread.isAlive());
        /**
         * 线程休眠
         */
        myThread.sleep(1000);
        System.out.println("状态睡眠=========" + myThread.isAlive());
        /*
         *线程等待
         */
        MyThread myThread1 = new MyThread();
        myThread1.start();
        synchronized (myThread1){
            System.out.println("状态2启动=========" + myThread.isAlive());
            Thread.State state = myThread1.getState();
            System.out.println(state);
            myThread1.wait(1000);//此时停止的是当前线程，并不是调用的
            state = myThread1.getState();
            System.out.println(state);
            System.out.println("状态=========" + myThread.isAlive());
        }

    }
}
